﻿@using S4sme.Web.Resources;
@using System.Collections.Specialized;
@model S4sme.Tasks.Blog.ViewModels.PostIndexViewModel

@{
    ViewBag.Keywords = Resource_Blog.BlogKeyWords;
    Layout = "../Shared/_BlogLayout.cshtml";
}

@helper Links(int currentPage, int totalPages, string previousPageText, string nextPageText) {

bool hasMorePages = currentPage < totalPages;
bool hasPrevPages = currentPage > 1;


<p class="morelink">

@if (hasPrevPages)
{
     <span class="leftfloat">&lt;&lt;&lt;@Html.ActionLink(previousPageText, "Index", new { page = currentPage - 1 })</span>
}

@if (hasMorePages)
{
     <span class="rightfloat">@Html.ActionLink(nextPageText, "Index", new { page = currentPage + 1 })&gt;&gt;&gt;</span>
}

</p>
}

<div id="maincntblog">

@foreach (var item in Model.RecentPosts)
{
    <div class="postcontent">
      <h3>
        <a href="@Url.Action("Details", "Posts",
             new
             {
                 slug = item.Slug
             })"
          rel="bookmark" title="Permanent Link to @item.Title">@item.Title</a></h3>      
      <div class="postbody">
        @item.Description
       </div>
       <div class="postinfo">Categories: @string.Join(", ", item.Categories.Select(c => c.Name)) <br />Tags: @string.Join(", ", item.Tags.Select(c => c.Name))</div>
      <div class="postdate">
        @item.CreatedDate.ToLongDateString()</div>
    </div>
}

@Links(Model.CurrentPage, Model.TotalPages, Resource_Blog.PreviousLink, Resource_Blog.MoreLink)

</div>